import { Context } from "../class/Context";
import { Buff } from "../class/Effect";
import { Method } from "../class/Method";
import { Role } from "../class/Role";

export class Eat extends Method {
    public CD: number = 30E3;
    static methodName: string = "吃";
    public describe: string = "吃了顿美食，使接下来的10秒内，每隔1秒回复 1%(lossHP) 生命值。";
    public invoke(context: Context) {
        this.masterRole.addEffectByClass(class extends Buff {
            public sumTime: number = 10E3;
            public eachTime: number = 1E3;
            public invoke(): void {
                const lossHP = this.masterRole.getMAXHP() - this.masterRole.getHP();
                const HP = Math.floor(lossHP * 0.01);
                this.masterRole.setHP(HP);
            }
        })
    }

}